#include <iostream>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    long long cows[60];
    int i, n;
    cows[1] = 1;
    cows[2] = 2;
    cows[3] = 3;
    cows[4] = 4;
    cows[5] = 6;
    for (i = 6; i < 60; i++)
    {
        cows[i] = cows[i - 1] + cows[i - 3];
    }
    while (cin >> n)
    {
        if (n == 0)
        {
            break;
        }
        cout << cows[n] << endl;
    }
    return 0;
}